flag_package: Option<String>,
flag_target: Option<String>,
flag_verbose: bool,
+ flag_release: bool,
}
pub const USAGE: &'static str = "
--no-run Compile, but don't run tests
-p SPEC, --package SPEC Package to run tests for
-j N, --jobs N The number of jobs to run in parallel
+ --release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
--target TRIPLE Build for the target triple
no_default_features: options.flag_no_default_features,
spec: options.flag_package.as_ref().map(|s| &s[..]),
exec_engine: None,
- release: false,
+ release: options.flag_release,
mode: ops::CompileMode::Test,
filter: if tests.is_empty() && bins.is_empty() {
ops::CompileFilter::Everything
RUNNING)));
});
+test!(cargo_test_release {
+ let p = project("foo")
+ .file("src/lib.rs", r#"
+ extern crate bar as the_bar;
+
+ pub fn bar() { the_bar::baz(); }
+
+ #[test]
+ fn foo() { bar(); }
+ "#)
+ .file("tests/test.rs", r#"
+ extern crate foo as the_foo;
+
+ #[test]
+ fn foo() { the_foo::bar(); }
+ "#)
+ .file("bar/Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+ authors = []
+
+ [lib]
+ name = "bar"
+ crate_type = ["dylib"]
+ "#)
+ .file("bar/src/lib.rs", "
+ pub fn baz() {}
+ ");
+
+ assert_that(p.cargo_process("test").arg("-v").arg("--release"),
+ execs().with_stdout(format!("\
+{compiling} bar v0.0.1 ({dir})
+{running} [..] -C opt-level=3 [..]
+{compiling} foo v0.0.1 ({dir})
+{running} [..] -C opt-level=3 [..]
+{running} [..] -C opt-level=3 [..]
+{running} `[..]target[..]foo-[..]`
+
+running 1 test
+test test_hello ... ok
+
+test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
+
+",
+ compiling = COMPILING, dir = p.url(), running = RUNNING)));
+});
+
test!(cargo_test_verbose {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))